import {tracker, trigger } from "./effect"
export const reactive = <T extends object>(value : T) => {
    // 代理对象
    return new Proxy(value,{
        get(target, key, receiver) {
            const res = Reflect.get(target,key,receiver)
            // 依赖收集函数调用
            tracker(target,key)
            return res
        },
        set(target, key, value, receiver) {
            const res = Reflect.set(target,key,value,receiver)
            // 依赖触发更新函数调用
            trigger(target,key)
            return res
        }
    })
}